﻿using System;
using System.Collections.Generic;
using System.Web.Security;

namespace DbExtendedProvider
{
	public interface IDbCommander
	{
		string DDLResourcePath { get; }
		string DMLResourcePath { get; }
		string ConnectionStringName { get; set; }

		string ApplicationName { get; set; }
		string ProviderName { get; set; }
		int LockoutTime { get; set; }

		void Initialize(string applicationName,
		                string providerName,
		                int lockoutTime);

		bool UserExistsByUserName(string userName);
		bool UserExistsByEmail(string email);
		bool UserExistsByUserId(Guid id);

		MembershipUser CreateStandardUser(
			string username,
			string salt,
			byte[] password,
			string comments,
			string email,
			out MembershipCreateStatus status,
			Guid id,
			string securityQuestion = null,
			string securityAnswerSalt = null,
			byte[] securityAnswer = null,
			bool enabled = true);

		bool ConnectionIsGood();

		byte[] GetEncryptedPassword(string username);
		HashGrouping GetHashedPassword(string username);
		HashGrouping GetHashedAnswer(string username);
		void UnlockUser(string username);

		void UpdateQuestionAndAnswer(string username,
		                             string question,
		                             string answerSalt,
		                             byte[] answerHash);

		void ChangeEncryptedPassword(string username,
		                             byte[] password);

		void ChangeHashedPassword(string username,
		                          string salt,
		                          byte[] hash);

		MembershipUser UpdateMembershipUser(MembershipUser user);
		MembershipUser GetMembershipUser(string userName);
		MembershipUser GetMembershipUser(Guid userId);
		IEnumerable<MembershipUser> GetMembershipUsersByEmail(string email);
		void RecordValidationEventById(Guid userId, bool success);
		void RecordValidationEventByUserName(string username, bool success);
	}
}